﻿Public Class frmRelanceOS
    Private szSQL As String
    Private rs As ADODB.Recordset = Nothing

    Private Sub frmRelanceOS_Load(sender As Object, e As System.EventArgs) Handles Me.Load

        InitListeDOSSIERS(0)

    End Sub

    Private Sub InitListeDOSSIERS(ByVal ix As Integer)

        Dim nb As Integer = 0

        ' effacer la listview
        LV_DOSSIERS.Items.Clear()

        ' affiche les 50 CABINETS à partir de l'élève courant
        szSQL = "CALL spGET_ENTETE_byCriteria('" & gSocieteCode & "','ORDRES','PARDATEREL','','',0)"
        GetRecordset(ctDSN_DEVFAC, szSQL, rs)

        Do While Not rs.EOF
            LV_DOSSIERS.Items.Add(rs.Fields("daterel").Value)
            LV_DOSSIERS.Items(nb).SubItems.Add(Format(rs.Fields("no_id").Value, "000000"))
            LV_DOSSIERS.Items(nb).SubItems.Add(rs.Fields("date").Value)
            LV_DOSSIERS.Items(nb).SubItems.Add(nv(rs.Fields("c_qualite").Value) & " " & nv(rs.Fields("c_nom").Value))
            LV_DOSSIERS.Items(nb).SubItems.Add(nv(rs.Fields("c_adr").Value))
            LV_DOSSIERS.Items(nb).SubItems.Add(rs.Fields("mttrav").Value)
            LV_DOSSIERS.Items(nb).SubItems.Add(GetLibST(rs.Fields("status").Value))
            If rs.Fields("daterel").Value < Now Then
                LV_DOSSIERS.Items(nb).ForeColor = Color.Red
            End If
            nb = nb + 1
            ' Get the next record
            rs.MoveNext()
        Loop
        ' Close the recordset AND connection.
        rs.Close()

        LB_NbLignes.Text = CStr(nb) & " fiche(s)"
        ' restaurer la position du curseur avant le init
        setIndice(ix, LV_DOSSIERS)

    End Sub

End Class